# -*- coding:utf8 -*-

###########################################
# Date: 05/11/11                          #
# Nom: Parallels Intelligences            #
# Copyright 2011: Rigaut Maximilien       #
###########################################
#    This file is part of Parallels Intelligences.
#
#    Adem is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    Parallels Intelligences is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Adem. If not, see <http://www.gnu.org/licenses/>.
########################################################

class cuve(Tk):
	def __init__(self,size=(400,500)):
		Tk.__init__(self)
		self.size=vector(*size)
		#self.columnconfigure(0, weight=1)
		#self.rowconfigure(0, weight=1)
		self.canvas = Canvas(self,width=size[0],height=size[1])
		self.canvas.grid(column=0, row=0)#, sticky=(N, W, E, S))
		self.particules=[]
		self.grid=[[]]*(size[0]*size[1]/UIP_SIZE)
	def live(self):
		for part in self.particules:
			for i in neigh(part,self.size):
				#self.grid[part.place[0]/UIP_SIZE+size[0]*part.place[1]/UIP_SIZE]+=[part]
				pass
	def place2list(self,particule): return particule.place[0]+particule.place[1]*self.size[0]/UIP_SIZE
	def list2place(self,place):
		x=place%self.size[0]
		y=(place-x)/UIP_SIZE
		return x,y
	def neigh(self,part):
		grid/=UIP_SIZE
		x,y=part[0],part[1]
		print part[0]+part[1]*grid[0]
		return [x,y]